package com.biz.primus.ms.adv.dao.po;

import com.biz.primus.model.adv.enums.AdUsePlace;
import com.biz.primus.model.adv.enums.UseType;
import com.biz.primus.ms.base.jpa.po.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;

/**
 * 广告位
 *
 * @author jun.liu
 * @date 2017-09-18
 */
@Entity
@Table(name = "ad_position")
@Data
@EqualsAndHashCode(callSuper=true)
public class AdPosition extends BaseEntity {

    /**
     * 名称
     */
    @Column(name = "name", nullable = false, length = 32)
    private String name;

    /**
     * 宽度
     */
    @Column
    private Integer width;

    /**
     * 高度
     */
    @Column
    private Integer height;

    /**
     * 描述
     */
    @Column(name = "description", length = 200)
    private String description;

    /**
     * 广告位使用类型
     */
    @Column(length = 30, nullable = false)
    @Enumerated(EnumType.STRING)
    private UseType useType;

    /**
     * 是否启用 (注意：位“true” 时位有效，即启用，反之则为禁用)
     */
    @Column
    private boolean invalid = true;

    /**
     * 广告
     */
    @OneToMany(mappedBy = "adPosition", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    private List<Advertisement> ads;

    /**
     * 标识使用地方
     */
    @Column(length = 30, nullable = false)
    @Enumerated(EnumType.STRING)
    private AdUsePlace adUsePlace;

}


